﻿using System;
using System.Linq;

class SelectManyExample
{
    static void Main()
    {
        var students =
        new[] {  
            new { Name = "Pesho", Courses = new string[] {".NET", "PHP" }},
            new { Name = "Pesho", Courses = new string[] {"Java", "PHP" , "SQL"}},
            new { Name = "Pesho", Courses = new string[] {"Java", "PHP" }},
            new { Name = "Pesho", Courses = new string[] {".NET", "Java" }},
            new { Name = "Pesho", Courses = new string[] {".NET", "PHP" }}
        };

      //  var courses = students.SelectMany(s => s.Courses).Distinct().OrderBy(s=>s);
        var courses = (from s in students
                      from p in s.Courses
                      orderby p
                      select p).Distinct();

        
        
        foreach (var c in courses)
        {
            Console.WriteLine(c);
        }
    }
}
